Class Filters

Summary

Fully Qualified Name: CodeIgniter\View\Filters

Description

View filters

Methods

Name Description Defined By
capitalize() Returns $value as all lowercase with the first letter capitalized. Filters
date() Formats a date into the given $format. Filters
date_modify() Given a string or DateTime object, will return the date modified by the given value. Returns the value as a unix timestamp Filters
default() Returns the given default value if $value is empty or undefined. Filters
esc() Escapes the given value with our `esc()` helper function. Filters
excerpt() Returns an excerpt of the given string. Filters
highlight() Highlights a given phrase within the text using '' tags. Filters
highlight_code() Highlights code samples with HTML/CSS. Filters
limit_chars() Limits the number of characters to $limit, and trails of with an ellipsis. Filters
limit_words() Limits the number of words to $limit, and trails of with an ellipsis. Filters
local_currency() Returns the $value displayed as a currency string. Filters
local_number() Returns the $value displayed in a localized manner. Filters
nl2br() Returns a string with all instances of newline character (\n) converted to an HTML
tag.
Filters
prose() Takes a body of text and uses the auto_typography() method to turn it into prettier, easier-to-read, prose. Filters
round() Rounds a given $value in one of 3 ways; Filters
title() Returns a "title case" version of the string. Filters

Method Details

capitalize()

Returns $value as all lowercase with the first letter capitalized.

Parameter Name Type Description
$value
$value

Returns: string

date()

Formats a date into the given $format.

Parameter Name Type Description
$value
$format string
$value

Returns: string

date_modify()

Given a string or DateTime object, will return the date modified by the given value. Returns the value as a unix timestamp

Example: my_date|date_modify(+1 day)

Parameter Name Type Description
$value
$adjustment string
$value

Returns: string

default()

Returns the given default value if $value is empty or undefined.

Parameter Name Type Description
$value
$default string
$value

Returns: string

esc()

Escapes the given value with our `esc()` helper function.

Parameter Name Type Description
$value
$context string
$value

Returns: string

excerpt()

Returns an excerpt of the given string.

Parameter Name Type Description
$value string
$phrase string
$radius int

Returns: string

highlight()

Highlights a given phrase within the text using '' tags.

Parameter Name Type Description
$value string
$phrase string

Returns: string

highlight_code()

Highlights code samples with HTML/CSS.

Parameter Name Type Description
$value
$value

Returns: string

limit_chars()

Limits the number of characters to $limit, and trails of with an ellipsis.

Will break at word break so may be more or less than $limit.

Parameter Name Type Description
$value
$limit int
$value

Returns: string

limit_words()

Limits the number of words to $limit, and trails of with an ellipsis.

Parameter Name Type Description
$value
$limit int
$value

Returns: string

local_currency()

Returns the $value displayed as a currency string.

Parameter Name Type Description
$value
$currency string
$locale string|null
$fraction int
$value

Returns: string

local_number()

Returns the $value displayed in a localized manner.

Parameter Name Type Description
$value
$precision int
$type string
$locale string|null
$value

Returns: string

nl2br()

Returns a string with all instances of newline character (\n) converted to an HTML
tag.

Parameter Name Type Description
$value string

Returns: string

prose()

Takes a body of text and uses the auto_typography() method to turn it into prettier, easier-to-read, prose.

Parameter Name Type Description
$value string

Returns: string

round()

Rounds a given $value in one of 3 ways;

Parameter Name Type Description
$value string
$precision mixed
$type string

Returns: string

title()

Returns a "title case" version of the string.

Parameter Name Type Description
$value string

Returns: string

Top